package com.zyz.M_File和IO流.File类.文件和目录基本信息;

import java.io.File;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * @author: vick
 * @Date: 2025/4/7
 * @Description:
 * @version: 1.0
 */
public class Demo {
    public static void main(String[] args) {
        File file = new File("D:\\environment\\ideaProject\\java-Phase-one\\java_study\\jdbc.properties");
        System.out.println("构造路径：" + file.getParent());
        System.out.println("文件名称：" + file.getName());
        System.out.println("文件长度：" + file.length() + "字节");
        System.out.println("最后修改时间：" + new Date(file.lastModified()));
        System.out.println("最后修改时间：" + LocalDateTime.ofInstant(Instant.ofEpochMilli(file.lastModified()), ZoneId.of("Asia/Shanghai")));
        SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = simpleDateFormat1.format(new Date(file.lastModified()));
        System.out.println("最后修改时间：" + format);
    }
}
